package cn.edu.neusoft.zengweidong707.neufood.model;

import java.util.List;

import cn.edu.neusoft.zengweidong707.neufood.bean.FoodByIdBean;
import cn.edu.neusoft.zengweidong707.neufood.bean.FoodListBean;
import cn.edu.neusoft.zengweidong707.neufood.bean.IsCollectedBean;
import cn.edu.neusoft.zengweidong707.neufood.bean.IsSuccessBean;
import cn.edu.neusoft.zengweidong707.neufood.bean.LoginBean;
import cn.edu.neusoft.zengweidong707.neufood.bean.ShopListBean;
import cn.edu.neusoft.zengweidong707.neufood.bean.UserByIdBean;
import cn.edu.neusoft.zengweidong707.neufood.bean.UserCollectionListBean;
import cn.edu.neusoft.zengweidong707.neufood.bean.UserOrderBean;
import cn.edu.neusoft.zengweidong707.neufood.iface.ZwdIface;
import cn.edu.neusoft.zengweidong707.neufood.listener.ListListener;
import cn.edu.neusoft.zengweidong707.neufood.listener.ZwdListener;
import retrofit2.Call;

/**
 * Created by Lucio on 2017/11/2.
 */

public class UserModel extends RetrofitBaseModel implements ZwdIface {

    @Override
    public void login(String u, String p, final ZwdListener l) {
        getRetrofit();
        getService();
        Call<LoginBean> call = service.login(u, p);
        callenqueue(call, l);
    }

    @Override
    public void reg(String usename, String userpass, String mobilenum, String address, String comment, final ZwdListener l) {
        getRetrofit();
        getService();
        Call<IsSuccessBean> call = service.reg(usename, userpass, mobilenum, address, comment);
        callenqueue(call, l);
    }

    @Override
    public void getShopList(final ListListener list) {
        getRetrofit();
        getService();
        Call<List<ShopListBean>> call = service.getShop();
        callenqueue(call, list);
    }

    @Override
    public void getFoodList(final ListListener list, int shop_id) {
        getRetrofit();
        getService();
        Call<List<FoodListBean>> call = service.getFood(shop_id);
        callenqueue(call, list);
    }

    @Override
    public void getFoodByID(int id, final ZwdListener l) {
        getRetrofit();
        getService();
        Call<FoodByIdBean> call = service.getFoodById(id);
        callenqueue(call, l);
    }

    @Override
    public void userBuyFood(int user_id, int food_id, int num, Double sum, String suggesttime, final ZwdListener l) {
        getRetrofit();
        getService();
        Call<IsSuccessBean> call = service.buyFood(user_id, food_id, num, sum, suggesttime);
        callenqueue(call, l);
    }

    @Override
    public void userCollectionShop(int userid, int shopid, ZwdListener l) {
        getRetrofit();
        getService();
        Call<IsSuccessBean> call = service.getShopCollection(userid, shopid);
        callenqueue(call, l);
    }

    @Override
    public void userCollectionFood(int userid, int foodid, ZwdListener l) {
        getRetrofit();
        getService();
        Call<IsSuccessBean> call = service.getFoodCollection(userid, foodid);
        callenqueue(call, l);
    }

    @Override
    public void shopCollectionFlag(int user_id, int shop_food_id, int flag, ZwdListener l) {
        getRetrofit();
        getService();
        Call<IsCollectedBean> call = service.getCollected(user_id, shop_food_id, flag);
        callenqueue(call, l);
    }

    @Override
    public void foodCollectionFlag(int user_id, int shop_food_id, int flag, ZwdListener l) {
        getRetrofit();
        getService();
        Call<IsCollectedBean> call = service.getCollected(user_id, shop_food_id, flag);
        callenqueue(call, l);
    }

    @Override
    public void getAllUserCollection(int userid, int flag, ListListener list) {
        getRetrofit();
        getService();
        Call<List<UserCollectionListBean>> call = service.getUserCollectionList(userid, flag);
        callenqueue(call, list);
    }

    @Override
    public void getSearch(String search, ListListener list) {
        getRetrofit();
        getService();
        Call<List<FoodListBean>> call = service.getSearchList(search);
        callenqueue(call, list);
    }

    @Override
    public void getUserInfo(int userid, ZwdListener l) {
        getRetrofit();
        getService();
        Call<UserByIdBean> call = service.getUserById(userid);
        callenqueue(call, l);
    }

    @Override
    public void getOrderByUserid(int userid, ListListener list) {
        getRetrofit();
        getService();
        Call<List<UserOrderBean>> call = service.getUserOrder(userid);
        callenqueue(call, list);
    }

    @Override
    public void getUserComment(int food_id, ListListener list) {
        getRetrofit();
        getService();
        Call<List<UserOrderBean>> call = service.getFoodOrder(food_id);
        callenqueue(call, list);
    }

    @Override
    public void insertCommentByOrderid(int order_id, String content, ZwdListener l) {
        getRetrofit();
        getService();
        Call<IsSuccessBean> call = service.insertComment(order_id, content);
        callenqueue(call, l);
    }

    @Override
    public void getCommentByUserid(int userid, ListListener list) {
        getRetrofit();
        getService();
        Call<List<UserOrderBean>> call = service.getUserComment(userid);
        callenqueue(call, list);
    }

    @Override
    public void updateUserInfo(int userid, String username, String userpass, String mobilenum, String address, ZwdListener l) {
        getRetrofit();
        getService();
        Call<IsSuccessBean> call = service.getUserInfo(userid, username, userpass, mobilenum, address);
        callenqueue(call, l);
    }


}
